<template>
  <transition name="edit">
    <div class="todo-editing" v-if="!!editing">
      <app-bar title="添加新任务" left="close" @left="toggleEditing"></app-bar>
      <div class="todo-editing_head">
        <p>还有什么事情要做呢?</p>
      </div>
      <div class="todo-editing_body">
        <textarea
          onfocus="this.placeholder=''"
          onblur="this.placeholder='添加一条新任务吧'"
          v-model="editing.text"
          rows="3"
          placeholder="添加一条新任务吧"
        ></textarea>
        <p class="todo-editing_meta">
          <i :class="['fa', `fa-${selected.todo.icon}`]"></i>
          {{ selected.todo.name }}
        </p>
        <p class="todo-editing_meta">
          <i class="fa fa-calendar"></i>
          Today
        </p>
      </div>
    </div>
  </transition>
</template>

<script>
import { mapState, mapMutations } from "vuex";
import AppBar from "./AppBar";
export default {
  components: {
    AppBar
  },
  computed: {
    ...mapState(["selected", "editing"])
  },
  methods: {
    ...mapMutations(["toggleEditing"])
  }
};
</script>

<style lang="scss" scoped>
.todo-editing {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background-color: white;
  color: #666;
  will-change: transform;
  .todo-editing_head {
    padding: 40px;
    color: #999;
  }
  .todo-editing_body {
    padding: 0 40px;
    textarea {
      margin: 6px 0;
      padding: 10px 10px;
      border: 1px solid #eee;
      outline: none;
      width: 100%;
      resize: none;
      color: #666;
      font-size: 28px;
      line-height: 1.2em;
      &::placeholder {
        font-size: 14px;
        color: rgba(153, 153, 153, 0.432);
        text-indent: 1em;
      }
    }
    .todo-editing_meta {
      display: flex;
      height: 44px;
      align-items: center;
      border-bottom: 1px solid #eee;
      color: #999;
      i {
        padding-right: 10px;
      }
    }
  }
}
.edit-leave-to,
.edit-enter {
  transform: translateY(100%);
}
.edit-enter-to,
.edit-leave {
  transform: translateY(0);
}
.edit-enter-active,
.edit-leave-active {
  transition: all 0.5s ease;
}
</style>
